<%@page import="bc.swim2.ejb.entity.RegisteredUser"%>
<%@page import="bc.swim2.ejb.entity.Ability"%>
<%@page import="bc.swim2.ejb.entity.Feedback"%>


<%@ page language="java"
	import="java.util.*,bc.swim2.ejb.entity.Feedback"
	import="java.util.*,bc.swim2.ejb.entity.Ability"
	contentType="text/html; charset=ISO-8859-1" pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Feedback</title>
<style>
@import url(css/main.css);
</style>
</head>
<body>
	<div id="allContainer">
		<div id="titleContainer">
			<%
				RegisteredUser currentUser = (RegisteredUser) (session
						.getAttribute("currentSessionUser"));
			%>
			<img src="img/swimScritta.gif" id="imageFloat" width=100px;
				height="100px">
			<h1 id="userHomeTitle">
				Welcome,
				<%=currentUser.getFirstName() + " "
					+ currentUser.getLastName()%>!
			</h1>
		</div>
		<div id="container">
			<div id="navigationContainer">
				<a href="MainServlet?to=RegisteredUserHome" id="linkRef">Home</a> <br />
				<a href="MainServlet?to=SearchHelp" id="linkRef">Search Help</a> <br />
				<a href="MainServlet?to=SearchUsers" id="linkRef">Search Users</a> <br />
				<a href="MainServlet?to=MyAbilities" id="linkRef">Declare/Remove
					ability</a> <br /> <a href="MainServlet?to=FriendshipRequests"
					id="linkRef">Friendship Requests</a> <br /> <a
					href="MainServlet?to=Friends" id="linkRef">Your Friends</a> <br />
				<a href="MainServlet?to=MyFeedback" id="linkRef">Feedback</a> <br />
				<a href="MainServlet?to=AbilityRequest" id="linkRef">Ability
					Request</a> <br /> <a href="LoginServlet?methodName=logout"
					id="linkRef">Logout</a>
			</div>
			<div id="actionContainer">
				<%
					if (!(request.getAttribute("me").equals("yes"))) {
						RegisteredUser profileUser = (RegisteredUser) (session
								.getAttribute("profileUser"));
				%>
				<h1 id="listTitle"><%=profileUser.getFirstName()%>'s feedbacks:
				</h1>
				<%
					} else {
				%>

				<h1 id="listTitle">Your feedbacks:</h1>
				<%
					}
					int i = 0;
					List<Feedback> feedbacks = null;
					feedbacks = (List<Feedback>) request.getAttribute("feedbackList");
					List<RegisteredUser> user = null;
					user = (List<RegisteredUser>) request.getAttribute("senderUsers");
					List<Ability> ability = null;
					ability = (List<Ability>) request.getAttribute("ability");
					String text = null;
					String score;
				%>
				<%
					for (Feedback f : feedbacks) {

						Ability a = ability.get(i);
						text = f.getText();
						if (text == null)
							text = "not expressed";
						if (f.getScore())
							score = "Good";
						else
							score = "Bad";
				%>
				<div id="separator"></div>
				<table>
					<tr>
						<td><label id="listLabelA">Sent by:</label></td>
						<td><%=user.get(i).getFirstName()%></td>
						<td><%=user.get(i).getLastName()%></td>
					</tr>
				</table>
				<table>
					<tr>
						<td><label id="listLabelA">Ability:</label></td>
						<td><%=ability.get(i).getName()%></td>
					</tr>
				</table>
				<table>
					<tr>
						<td><label id="listLabelA">Comment:</label></td>
						<td><%=text%></td>
					</tr>
				</table>
				<table>
					<tr>
						<td><label id="listLabelA">Valuation:</label></td>
						<%
							if (score.equals("Good")) {
						%>
						<td id="green"><%=score%></td>
						<%
							} else if (score.equals("Bad")) {
						%>
						<td id="red"><%=score%></td>
						<%
							}
						%>
					</tr>
				</table>

				<%
					i++;
					}
				%>


			</div>
		</div>
	</div>
</body>
</html>